From: Andrew Cooper Date: Fri, 13 May 2016 18:38:41 +0000 (+0100) Subject: x86/cpuid: Avoid unconditionally clobbering ITSC for guests X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~1111 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=a5adcee740df2679cf6828535279d8f8cbe2eff1;p=xen.git x86/cpuid: Avoid unconditionally clobbering ITSC for guests In general, Invariant TSC is not a feature which can be advertised to guests, because it cannot be guaranteed across migrate. domain_cpuid() goes so far as to deliberately clobber the feature flag under a number of circumstances. Because ITSC is absent from the static {pv,hvm}_featureset masks, c/s b648feff "xen/x86: Improvements to in-hypervisor cpuid sanity checks" caused ITSC to be unconditionally masked out. As an interim solution, include the hosts idea of ITSC along with the static {pv,hvm}_featureset when restricting the guests view of features. This causes the hardware domain, and VMs explicitly configured with ITSC and no-migrate to be offered ITSC (subject to hardware availability). Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich Release-acked-by: Wei Liu --- diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 7492030a13..5040a5c864 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -3509,7 +3509,8 @@ void hvm_cpuid(unsigned int input, unsigned int *eax, unsigned int *ebx, break; case 0x80000007: - *edx &= hvm_featureset[FEATURESET_e7d]; + *edx &= (hvm_featureset[FEATURESET_e7d] | + (host_featureset[FEATURESET_e7d] & cpufeat_mask(X86_FEATURE_ITSC))); break; case 0x80000008: diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index 0052ab8a0f..1ef8401b01 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -1142,7 +1142,8 @@ void pv_cpuid(struct cpu_user_regs *regs) break; case 0x80000007: - d &= pv_featureset[FEATURESET_e7d]; + d &= (pv_featureset[FEATURESET_e7d] | + (host_featureset[FEATURESET_e7d] & cpufeat_mask(X86_FEATURE_ITSC))); break; case 0x80000008: